var vue = new Vue({
  el: '#record',
  data: {
    multipleSelection: [],
    title: '',
    days: '',
    record: '',
    orgInfo: {},
    meetingData: [],
    totalSize: 0,
    pageIndex: 1,
    pageSize: 10,
    directorOptions: [],
    companyOptions: [],
    pickerOptions1: {
      disabledDate(time) {
        return time.getTime() > Date.now()
      }
    },
    // 添加界面表单
    form: {
      id_discuss: '',
      id_meeting: '',
      content: '',
      date_meeting: ''
    },
    formLabelWidth: '120px',
    //对话框显示状态
    addVisible: false

  },
  created: function() {
    this.getDic()
  },
  mounted() {
    this.initGrid()
  },

  methods: {

    getDic: function() {
      var that = this
      $.get('meetingUser/getOrgInfo', function(result) {
        that.orgInfo = result.data
      })
    },
    // 初始化表格
    initGrid: function() {
      var that = this
      $.post('discussDD/listByPageByDate', {
        index: that.pageIndex,
        size: that.pageSize,
        orgId: that.orgInfo.orgId
      }, function(result) {
        that.totalSize = result.data.total
        that.meetingData = result.data.data
      })
    },
    //翻页
    handleSizeChange(val) {
      this.pageSize = val
      this.initGrid()
    },
    //改变每页显示条数
    handleCurrentChange(val) {
      this.pageIndex = val
      this.initGrid()
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    // 添加记录
    talking(row) {
      console.log(row)
      this.form.id_discuss = row.id_discuss
      this.form.id_meeting = row.id_meeting
      this.form.date_meeting = row.date_meeting
      this.form.content = row.content
      this.addVisible = true
    },
    //添加会议
    addTalking: function() {
      var that = this
      $.post('discussDD/save', {
        id_discuss: that.form.id_discuss,
        id_meeting: that.form.id_meeting,
        date_meeting: that.form.date_meeting,
        content: that.form.content
      }, function(result) {
        if (result.data) {
          that.$message({
            message: '发言成功',
            type: 'success'
          })
          that.addVisible = false
          that.form.content = ''
          that.initGrid()
        } else {
          that.$message({
            message: '发言失败',
            type: 'warning'
          })
        }
      })
    },
    //关闭dialog前执行的方法
    handleClose(done) {
      var that = this
      this.$confirm('确认关闭？')
        .then(_ => {
          if (that.addVisible) {
            that.addVisible = false
            this.$refs['form'].resetFields()
          }
        })
        .catch(_ => {
        })
    }
  }
})
